<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>列表</title>
    <link rel="stylesheet" href="../css/qt/footer.css">
    <link rel="stylesheet" href="../css/qt/nav.css">
    <link rel="stylesheet" href="../css/qt/list.css">
    <script src="../JS/jquery-1.12.4.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
            list-style: none;
        }
    </style>
</head>
<body>
<!-- 顶部导航starting -->
<?php
require('../qt/common/list_nav.php')
?>
<!-- nav ending -->
<!-- 主题内容starting -->

<!-- 连接数据库操作  -->
<?php
error_reporting(0);
mysql_connect("localhost","root","1161105403");
mysql_select_db("blog");
mysql_query("set names utf8");
//类型id是通过GET方法提交的
//根据类型id从数据库中查询属于该类型的所有博文信息
$tid=$_GET['tid'];
$sql0="select * from blogtype where tid=$tid";
$result0 = mysql_query($sql0) or die('查询失败！'.mysql_error());
$row0 = mysql_fetch_assoc($result0);
$sql = "select * from blogs where tid={$tid}";
$result = mysql_query($sql) or die('查询失败！'.mysql_error());
//获取指定的页码
//判断是否指定第几页，如果没有指定，则显示第1页。
if(!isset($_GET["page"]))
    $page=1;
else{
    $page=$_GET["page"];
}
//获取总行数，用于计算分几页显示
$result = mysql_query($sql);
$totalrows = mysql_num_rows($result);
//定义每页显示的行数
$rowsperpage =5;
//计算从表中第几行开始输出
$start = ($page-1) * $rowsperpage;
//查询用户，从第$start行开始，共查询$rowsperpage行。
$sql .= " limit {$start}, {$rowsperpage}";
//echo $sql.'<br/>';
//执行sql语句
$result = mysql_query($sql) or die('查询失败！'.mysql_error());
?>

<div class="main clearfix">
    <!-- 左边starting -->
    <div class="m_left">
        <!--   分类starting    -->
        <h2>文章类别为:<?php echo $row0["typename"];?></h2>
        <!--   分类ending   -->
        <?php
        while($row=mysql_fetch_assoc($result))
        {
        ?>
        <div  class="excerpt">
            <div class="title">
                <a  href="show.php?bid=<?php
                echo $row["bid"];
                ?>"><?php
                echo $row["title"];
                    ?></a>
            </div>
            <div class="img_left">
                <img src="../images/blog/<?php echo $row["pic"]?>" alt="<?php echo $row["pic"]?>" width="170" height="146">
            </div>
            <div class="content">
                <div class="top">
                    <?php
                    echo $row["intro"];
                    ?>
                </div>
                <div class="bottom">
                    <ul class="detail">
                        <li>
                            <img src="../images/Font_Icon/心.png" alt="收藏量" title="收藏量">
                            <span><?php
                                echo $row["like"];
                                ?></span>
                        </li>
                        <li>
                            <img src="../images/Font_Icon/眼睛.png" alt="游览量" title="游览量">
                            <span><?php
                                echo $row["visited"];
                                ?></span>
                        </li>
                        <li>
                            <img src="../images/Font_Icon/时钟.png" alt="上传时间" title="上传时间">
                            <span><?php
                                echo $row["uploaddate"];
                                ?></span>
                        </li>
                        <li>
                            <img src="../images/Font_Icon/沐歌.png"  alt="上传人" title="上传人">
                            <span><?php
                                echo $row["uploadadmin"];
                                ?></span>
                        </li>
                    </ul>
                </div>
            </div>
            <?php
            }
            ?>
        </div>
        <div class="search">
            <?php
            //计算总页数。如果每页显示的行数>总行数，则只有1页，否则，页数=总行数/每页行数，上取整
            if($rowsperpage >= $totalrows)
            $totalpages = 1;
            else{
            $totalpages = ceil($totalrows / $rowsperpage);
            }
            //如果不是第1页，则显示第一页和上一页的超链接，否则只显示文字
            if($page>1){
            $first = "<a href=?page=1&tid=$tid>首页</a>";
            $pre = "<a href=?tid=$tid&page=".($page-1).">上一页</a>";
            }else{
            $first = '首页';
            $pre = '上一页';
            }
            //如果不是最后一页，则显示下一页和最后一页的超链接，否则只显示文字
            if($page<$totalpages){
            $last = "<a href=?tid=$tid&page=$totalpages>尾页</a>";
            $next = "<a href=?tid=$tid&page=".($page+1).">下一页</a>";
            }else{
            $last = '尾页';
            $next = '下一页';
            }
            //输出分页
            echo "共{$totalrows}条记录&nbsp;&nbsp;";
            echo "$first"."&nbsp;&nbsp;";
            echo "$pre"."&nbsp;&nbsp;";
            for($i=1;$i<=$totalpages;$i++)
            echo "<a href=?tid=$tid&page=$i>第{$i}页</a>&nbsp;&nbsp;";
            echo "$next"."&nbsp;&nbsp;";
            echo "$last";
            ?>
         </div>
    </div>
    <!-- 左边ending -->

    <!-- 右边starting -->
    <div class="m_right">
        <div class="icon">
            <ul>
                <li><img src="../images/Font_Icon/QQ.png" width="40" height="40" alt="QQ"></li>
                <li><img src="../images/Font_Icon/webchat.png" width="40" height="40" alt="微信"></li>
                <li><img src="../images/Font_Icon/weibo.png" width="40" height="40" alt="微博"></li>
                <li><img src="../images/Font_Icon/email.png" width="40" height="40" alt="邮箱"></li>

            </ul>
        </div>
        <div class="r_excerpt ex1" id="slide-right">
            <!--轮播图starting-->
            <img src="../images/Carousel/1.jpg" width="330" height="130"/>
            <img src="../images/Carousel/2.jpg" width="330" height="130"/>
            <img src="../images/Carousel/3.jpg" width="330" height="130"/>
            <img src="../images/Carousel/4.jpg" width="330" height="130"/>
            <img src="../images/Carousel/5.jpg" width="330" height="130"/>
            <script type="text/javascript">
                var size = $('#slide-right img').size();
                var _index = size;
                var timer = null;
                $('#slide-right').append($('#slide-right img:eq(0)').clone());
                timer = setInterval(function () {
                    $('#slide-right img').eq(_index).fadeOut(800);
                    _index == 1 ? _index = size : _index--;
                    $('#slide-right img').eq(_index).fadeIn(800);
                }, 4000);
            </script>
            <!--轮播图ending-->
        </div>
        <div class="r_excerpt ex2">
            <h2 style="background-color: #FB4F4F;color: white"> 标签云集</h2>
            <button>div+css</button>
            <button>JavaScript</button>
            <button>PHP</button>
            <button>MySQL</button>
            <button>thinkPHP</button>
            <button>Python</button>
            <button>Git</button>
            <button>ajax</button>
            <button>jQuery</button>
        </div>
        <div class="r_excerpt ex3">
            <img src="../images/blog/小橘子.jpg" width="330" height="130" alt="">
        </div>
        <div class="r_excerpt ex4">
            <h2 style="background-color: #FB4F4F;color: white"> 猜你喜欢</h2>
            <ul>
                <li>*祖国70周年大阅兵...</li>
                <li>*女排世界冠军...</li>
                <li>*即便你长得不帅，也能撩妹的技能...</li>
                <li>*更多...</li>
            </ul>
        </div>
        <div class="r_excerpt FriendlyLink">
            <h2 style="background-color: #FB4F4F;color: white"> 友情链接</h2>
            <ul class="ul_left">
                <li>百度SEO</li>
                <li>Git中文社区</li>
                <li>系统之家</li>
            </ul>
            <ul class="ul_right">
                <li>bilibili弹幕网</li>
                <li>w3c school官网</li>
                <li>网站模板</li>
            </ul>
        </div>
    </div>
    <!-- 右边ending -->
</div>

<!-- 主题内容starting -->




</body>

</html>